package net.huashitong.synthetical.showView.util;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.List;

public class DataFormateUntil {
    public static String dataFormat(String str) {

        DecimalFormat df = new DecimalFormat("#.##");
        Double strDouble = Double.parseDouble(str);
        return df.format(strDouble);
    }

    public static String dataFormat1(String str) {

        DecimalFormat df = new DecimalFormat("#.#");
        Double strDouble = Double.parseDouble(str);
        return df.format(strDouble);
    }

    public static String dataFormat2(String str) {
        Double strDouble = Double.parseDouble(str);
        return String.format("%.2f",strDouble);
    }

    public static String dataFormat11(String str) {
        Double strDouble = Double.parseDouble(str);
        return String.format("%.1f",strDouble);
    }

    public static String dataformatUnit(String str) {
        DecimalFormat df = new DecimalFormat("#.##");
        Double strDouble = Double.parseDouble(str);
        strDouble = strDouble / 10000;
        return df.format(strDouble);
    }

    public static String dataformatQianUnit(String str) {
        DecimalFormat df = new DecimalFormat("#.##");
        Double strDouble = Double.parseDouble(str);
        strDouble = strDouble / 100000;
        return df.format(strDouble);
    }

    public static String dataformatBaiWangToYi(String str) {
        DecimalFormat df = new DecimalFormat("#.##");
        Double strDouble = Double.parseDouble(str);
        strDouble = strDouble / 100;
        return df.format(strDouble);
    }

    /**
     * list集合去除重复数据
     * @param list
     * @return
     */
    public static List removeDuplicate(List list) {
        for (int i = 0; i < list.size() - 1; i++) {
            for (int j = list.size() - 1; j > i; j--) {
                if (list.get(j).equals(list.get(i))) {
                    list.remove(j);
                }
            }
        }
        return list;
    }


    public static String kexuejishu(String data){
        BigDecimal bd = new BigDecimal(data);
        return bd.toPlainString();
    }
}
